import type { UserDetail } from '@/api/modules/user/types';
import type { Rule } from 'ant-design-vue/es/form';

const formObj: UserDetail = {
  roleIds: [],
  roles: [],
  user: {
    admin: false,
    avatar: '',
    deptId: '',
    email: '',
    lang: '',
    loginDate: '',
    loginIp: '',
    nickName: '',
    sex: '',
    status: '',
    telephone: '',
    timezone: '',
    password: '',
    userId: '',
    userName: '',
    storeNo: '',
    platform: '',
    roleIds: [],
    roles: [],
  },
};

export const userInfo = ref<UserDetail>({
  ...formObj,
});

export const formRef = ref();

export const resetForm = () => {
  userInfo.value = {
    ...formObj,
  };
};
export const formRules: Record<string, Rule[]> = {
  password: [{ required: true }],
  username: [{ required: true }],
  nickname: [{ required: true }],
  email: [{ required: true }],
  telephone: [{ len: 11 }],
  deptId: [],
  roleIds: [{ required: true }],
  roles: [],
  storeNo: [],
};
